<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	template="../WEB-INF/templates/layout.xhtml"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">

	<ui:define name="content">
		<h:form id="formpf">
			<h:panelGrid>
				<h:outputText value="Dados Pessoais" />
				<h:panelGroup>

					<h:outputLabel value="Nome" for="nome" />
					<h:inputText value="#{mbPessoaFisica.pf.nome}" id="nome"
						required="true" />
					<h:message for="nome" style="color:red" />

					<h:outputLabel value="CPf" for="cpf" />
					<h:inputText value="#{mbPessoaFisica.pf.cpf}" id="cpf">
						<f:validateLength for="cpf" minimum="10" />
					</h:inputText>
					<h:message for="cpf" style="color:red" />

					<h:outputLabel value="Email" for="email" />
					<h:inputText value="#{mbPessoaFisica.pf.email}" />
				</h:panelGroup>

				<h:outputText value="Endereço" />

				<h:panelGroup>

					<h:outputLabel value="Cep" for="cep" />
					<h:inputText value="#{mbPessoaFisica.endereco.cep}" id="cep" />

					<h:outputLabel value="Logradouro" for="logradouro" />
					<h:inputText value="#{mbPessoaFisica.endereco.logradouro}"
						id="logradouro" />

					<h:outputLabel value="Bairro" for="bairro" />
					<h:inputText value="#{mbPessoaFisica.endereco.bairro}" id="bairro" />

					<h:selectOneMenu value="#{mbPessoaFisica.endereco.cidade}"
						hideNoSelectionOption="true">
						<f:selectItems value="#{mbPessoaFisica.estados}" var="e"
							itemLabel="#{e.sigla}" itemValue="#{e.descricao}" />
					</h:selectOneMenu>

					<h:outputLabel value="Numero" for="numero" />
					<h:inputText value="#{mbPessoaFisica.endereco.numero}" id="numero" />
					<h:message for="numero" />

				</h:panelGroup>


			</h:panelGrid>

			<h:commandButton value="Gravar"
				action="#{mbPessoaFisica.inserirRegistro()}" />
		</h:form>


		<h:form>
			<rich:dataTable value="#{mbPessoaFisica.listPessoaFisica}" var="p">
				<rich:column>
					<f:facet name="header">Nome</f:facet>
					<h:outputText value="#{p.nome}" />
				</rich:column>

				<rich:column>
					<f:facet name="header">CPF</f:facet>
					<h:outputText value="#{p.cpf}" />
				</rich:column>

				<rich:column>
					<f:facet name="header">E-Mail</f:facet>
					<h:outputText value="#{p.email}" />
				</rich:column>

				<rich:column>
					<f:facet name="header">Data Nascimento</f:facet>
					<h:outputText value="#{p.dataNascimento.toDate()}">
						<f:convertDateTime type="date" pattern="dd/MM/yyyy"
							dateStyle="short" />
					</h:outputText>
				</rich:column>

				<rich:column>
					<f:facet name="header">Logradouro</f:facet>
					<h:outputText value="#{p.endereco.logradouro}" />
				</rich:column>

				<rich:column>
					<f:facet name="header">Cidade</f:facet>
					<h:outputText value="#{p.endereco.cidade}" />
				</rich:column>

				<rich:column>
					<f:facet name="header">Bairro</f:facet>
					<h:outputText value="#{p.endereco.bairro}" />
				</rich:column>

				<rich:column>
					<f:facet name="header">Editar</f:facet>
					<h:commandLink action="#{mbPessoaFisica.editar(p)}" value="Editar" />
				</rich:column>

				<rich:column>
					<f:facet name="header">Excluir</f:facet>
					<h:commandLink action="#{mbPessoaFisica.excluir(p)}" value="Excluir" />
				</rich:column>

			</rich:dataTable>
		</h:form>

	</ui:define>

</ui:composition>